/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package asistenciadb;

/**
 *
 * @author micael
 */

import java.sql.*;
public class conecta_mysql {
       static String bd = "db_asistencia";
       static String login = "asistencia";
       static String password = "db2011";
       static String url = "jdbc:mysql://localhost:3306/"+bd;
       static Connection conectar;
       Statement strStmt;
       ResultSet rs;

       public conecta_mysql() {

      conectar = null;
      try {

         Class.forName("com.mysql.jdbc.Driver");

         conectar = DriverManager.getConnection(url,login,password);
         strStmt = conectar.createStatement();

         if (conectar != null) {
            System.out.println("Conexión a base de datos "+url+" ... EXITOSA");
         }
      }
      catch(SQLException ex) {
         System.out.println("Hubo un problema al intentar conectarse con la base de datos "+url);
      }
      catch(ClassNotFoundException ex) {
         System.out.println(ex);
      }

   }
       public Connection getConexion(){
        return conectar;

    }
        public void desconectar(){
        conectar = null;
    }
       }
